import jsonschema

# 定义校验数据
resp = {"name": "张哈哈",
        "age": 21,
        "heigh": 1.76,
        "is_delete": True,
        "hobby": ["吃饭", "刷抖音", "睡觉"],
        "sex": None,
        "score": {"python": 88, "English": 99}}
# 定义规则
# sachema={"type":"object"}
# properties= {"age":21,}
# schema={"type":"null"}
# re=jsonschema.validate(instance=resp,schema=sachema)
# print(re)
# sachema = {"type": "object",
#            "properties": {"name": {"type": "string"},
#                           "age": {"type": "integer"},
#                           "heigh": {"type": "number"},
#                           "is_delete": {"type": "boolean"},
#                           "hobby": {"type": "array"},
#                           "sex": {"type": "null"},
#                           "score": {"type": "object",
#                                     "properties": {"python": {"type": "integer"}, "English": {"type": "integer"}}}
#                           }
#            }
# 定义一个校验规则
schema={
        "type":"object",
        "required":["name", "age", "heigh", "is_delete", "hobby", "sex", "score"]
        }
re = jsonschema.validate(instance=resp, schema=schema)
print(re)